/*
 * Copyright (C) 2012 Le Tuan Anh <anh.takaji@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ezcms.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Le Tuan Anh <anh.takaji@gmail.com>
 */
public class ConferenceItemSubmission implements Serializable {

    public static final int STATUS_SUBMITTED = 1;
    public static final int STATUS_PENDING_FOR_REVIEW = 2;
    public static final int STATUS_ACCEPTED = 3;
    public static final int STATUS_WITHDRAWN = 4;
    private long id;
    private List<User> authors;
    private ConferenceItemType submissionType;
    private Topic topic;
    private PresentationType presentationType;
    private List<FileResource> files;
    private String title;
    private String description;
    private List<Keyword> keywords;
    private int status;

    public ConferenceItemSubmission() {
        this.status = STATUS_SUBMITTED;
    }

    public ConferenceItemSubmission(
            Topic topic, ConferenceItemType submissionType,
            PresentationType presentationType, int status) {
        this();
        this.submissionType = submissionType;
        this.topic = topic;
        this.presentationType = presentationType;
    }

    public ConferenceItemSubmission(List<User> authors, ConferenceItemType submissionType, Topic topic, PresentationType presentationType, List<FileResource> file) {
        this();
        this.authors = authors;
        this.submissionType = submissionType;
        this.topic = topic;
        this.presentationType = presentationType;
        this.files = file;
    }

    public boolean isValid() {
        boolean valid = getAuthors().size() > 0 && topic != null;
        valid &= (this.getStatus() == STATUS_ACCEPTED || this.getStatus() == STATUS_PENDING_FOR_REVIEW
                || this.getStatus() == STATUS_SUBMITTED || this.getStatus() == STATUS_WITHDRAWN);
        return valid;
    }

    @Override
    public String toString() {
        return "ConferenceItemSubmission{" + "id=" + id
                + ", authors=" + authors + ", submissionType="
                + submissionType + ", topic=" + topic + ", presentationType="
                + presentationType + ", files=" + files + '}';
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the authors
     */
    public List<User> getAuthors() {
        if (authors == null) {
            authors = new ArrayList<>();
        }
        return authors;
    }

    /**
     * @param authors the authors to set
     */
    public void setAuthors(List<User> authors) {
        this.authors = authors;
    }

    /**
     * @return the submissionType
     */
    public ConferenceItemType getSubmissionType() {
        return submissionType;
    }

    /**
     * @param submissionType the submissionType to set
     */
    public void setSubmissionType(ConferenceItemType submissionType) {
        this.submissionType = submissionType;
    }

    /**
     * @return the topic
     */
    public Topic getTopic() {
        return topic;
    }

    /**
     * @param topic the topic to set
     */
    public void setTopic(Topic topic) {
        this.topic = topic;
    }

    /**
     * @return the presentationType
     */
    public PresentationType getPresentationType() {
        return presentationType;
    }

    /**
     * @param presentationType the presentationType to set
     */
    public void setPresentationType(PresentationType presentationType) {
        this.presentationType = presentationType;
    }

    /**
     * @return the file
     */
    public List<FileResource> getFiles() {
        return files;
    }

    /**
     * @param file the file to set
     */
    public void setFiles(List<FileResource> files) {
        this.files = files;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public List<Keyword> getKeywords() {
        return keywords;
    }

    public void setKeywords(List<Keyword> keywords) {
        this.keywords = keywords;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
